﻿//++
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// Module Name:
//
//    OutlookReminderInspectorTest.cs
//
// Abstract:
//
//    Unit tests for OutlookReminderInspector class
//
//--

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Microsoft.Office.Interop.Outlook;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestHelpers = Microsoft.EnhancedReminders.UnitTests.Helpers;

namespace Microsoft.EnhancedReminders.OutlookAddIn.UnitTests
{
    
    
    /// <summary>
    ///This is a test class for OutlookReminderInspectorTest and is intended
    ///to contain all OutlookReminderInspectorTest Unit Tests
    ///</summary>
    [TestClass()]
    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable",
        Justification = "AutoResetEvents are enclosed within using block")]
    public sealed class OutlookReminderInspectorTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for OutlookWindow_Close
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Microsoft.EnhancedReminders.OutlookAddIn.dll")]
        public void OutlookWindowCloseTest()
        {
            MockInspector inspector = new MockInspector(new MockAppointmentItem(OlResponseStatus.olResponseNone));
            Debug.Assert(inspector != null, "Failed to create MockInspector");

            OutlookReminderInspector_Accessor reminderInspector = new OutlookReminderInspector_Accessor(inspector);
            Debug.Assert(reminderInspector != null, "Failed to create OutlookReminderInspector_Accessor");

            reminderInspector.OutlookWindow_Closed();

            Assert.IsNull(reminderInspector._appointment, "_appointment is nulled");
            Assert.IsNull(reminderInspector._backgroundWorker, "_backgroundWorker is disposed");
            Assert.IsNull(reminderInspector._window, "_window is nulled");
        }

        /// <summary>
        ///A test for OutlookReminderInspector Constructor
        ///</summary>
        [TestMethod()]
        public void OutlookReminderInspectorConstructorTest()
        {
            MockInspector inspector = new MockInspector(new MockAppointmentItem(OlResponseStatus.olResponseAccepted));
            Debug.Assert(inspector != null, "Failed to create MockInspector");

            OutlookReminderInspector_Accessor reminderInspector = new OutlookReminderInspector_Accessor(inspector);
            TestHelpers.WaitOne(reminderInspector._backgroundWorkerCompletedEvent, "_backgroundWorkerCompletedEvent");
        }
    }
}
